import request from "@/utils/request";

//创建订单
export function addOrder(orderData) {
    return request({
        url: '/order/create',
        method: 'POST',
        data: orderData
    })
}

//更新订单状态
export function updatePaymentStatus(orderId, status) {
    return request({
        url: '/updateStatus',
        method: 'PUT',
        params: {
            orderId,
            status     
        }
    })
}

//查询订单详情
export function getCart(orderId){
    return request({
       url:'/order/withId',
       method:'GET',
       params:{
        orderId
       }
    })
   }

//获取收货地址列表
export function getAddresses() {
  return request.get('/address/page')
}

// 新增地址
export function addAddress(data) {
    return request.post('/address/add', data)
}

// 更新地址
export function updateAddress(data) {
    return request.put('/address/update', data)
}

// 删除地址
export function deleteAddress(id) {
    return request.delete(`/address/delete/${id}`)
}


export function getOrderList (params) {
    return request({
      url: '/order/list',
      params: params
    })
  }